package p8_5;

public class DataSet {
	
	private double sum;
	private Object maximum;
	private Object minimum;
	private int count;
	private IMeasurer measurer;
	
	public DataSet(IMeasurer aMeasurer)
	{
		sum=0;
		count=0;
		maximum=null;
		minimum=null;
		measurer=aMeasurer;
	}
	
	public void add(Object x)
	{
		sum = sum + measurer.measure(x);
		if (count ==0|| measurer.measure(maximum)<measurer.measure(x))
			maximum = x;
		if (count ==0|| measurer.measure(minimum)>measurer.measure(x))
			minimum = x;
	}
	
	public Object getMaximum()
	{
		return maximum;
	}
	
	public Object getMinimum()
	{
		return minimum;
	}

}
